<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="author" content="wangyupeng">
	<title>定制个人卡</title>
	<script language="javascript" src="../script/common.js" type="text/javascript"></script>
	<script language="javascript" type="text/javascript" src="../script/print.js"></script>	
	<script type="text/javascript">
		//全局变量
		function load(){
			Eui.showNavigation();											// 显示导航栏
			setPages(["readcardview","detview"])
			CardMgnt.customer.show("customerdiv",null,CardMgnt.PERSONALALL,{isCreate:true})
			CardMgnt.cardUser.show("carduserdiv",null,CardMgnt.PERSONALALL)
		}
		
		//定制卡片
		function customizeCard(){
			if (!checkForm(CardMgnt.customer.formName)) return;
			if (!checkForm(CardMgnt.cardUser.formName)) return;
			if (!checkForm(moneyform)) return;
		
			if (!showQuestion("是否定制个人卡？")) return;
			
			var customer = CardMgnt.customer.get();
			if (!customer.checkIdno){
				var c = DWR.syncCall("customerService.getCustomerForCardUser",customer.idno,customer.idnoType);
				if (c){
					if (!showQuestion("档案已经存在，是否在该档案下继续创建客户资料？")){onCancel();return;}
					customer.id = c.id
				}
			}
			var cardUser = CardMgnt.cardUser.get();
			cardUser.type = CardUserType.NAME;
			cardUser.cardType = moneyform.cardType.value;
			
			var data;
			try{
				data = DWR.syncCall("cardMgntService.customizePersonalCard",customer,cardUser);
			}catch(e){showError(e.description);return;}
			showInformation("定制卡片申请成功！");
			
			switchPage("detview");
			CardMgnt.showPrintView("detview","customize_personal_bill",data.logId,"定制个人卡凭证");
			try{WebPrint.print('billview');}catch(e){showWarning("打印出错："+e.description);return;}
		}
		
		//重置
		function onCancel(){
			switchPage("readcardview");
			moneyform.reset();
			CardMgnt.customer.show("customerdiv",null,CardMgnt.PERSONALALL,{isCreate:true})
			CardMgnt.cardUser.show("carduserdiv",null,CardMgnt.PERSONALALL)
		}
		function selCardType(){
			CardStore.selCardType(function(ct){
				moneyform.cardTypeName.value = ct[1];
				moneyform.cardType.value = ct[0];
				
				var fee = CardMgnt.getFee(Constants.ACCOUNT_FEE_CUSTOMIXE_CARD,ct[0]);
				var foregift = CardMgnt.getFee(Constants.ACCOUNT_FOREGIFT_CARD,ct[0]);
				moneyform.feeText.value = Format.fenToYuan(fee);
				moneyform.foregiftText.value = Format.fenToYuan(foregift);
			},{defBaseCardType:BaseCardType.PERSONAL,anonymous:true,userLevel : UserLevel.NORMAL})
		}
		</script>
	</head>
	<body onload="load()">
	<!--页面导航-->
	<div class="nav"><div id="nav">&nbsp;</div></div>
	
	<div id="readcardview">
		<div id="customerdiv" class="form"></div>
		<div class="form">
			<div id="carduserdiv"></div>
			<form id="moneyform" name="moneyform">
				<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="col2 label6">
					<tr>
						<td><label>卡 类 型</label>
							<input type="text" name="cardTypeName" maxlength="20" readonly class="readonly" onblur="checkV(this,'',true)"><a class="orga" href="#" onclick="selCardType()">&nbsp;&nbsp;</a><span class="des">*</span>
							<input type="hidden" name="cardType">
						</td>
						<td><label>押 金</label> <input type="text" name="foregiftText" readonly class="readonly"></td>
						
					</tr>
					<tr>
						<td><label>手续费</label> <input type="text" name="feeText" readonly class="readonly"></td>
						<td>&nbsp;</td>
					</tr>
				</table>
			</form>
		</div>
		<p>
			<button onclick="customizeCard()">定制卡片</button>
			<button onclick="onCancel()">重 置</button>
		</p>
	</div>
	
	<!--售卡明细页面-->
	<div id="detview" style="display:none;">
	</div>
</body>
</html>